import { Routes, Route } from "react-router-dom";
import Home from "@/pages/Home";
import TeacherLogin from "@/pages/TeacherLogin";
import StudentLogin from "@/pages/StudentLogin";
import TeacherDashboard from "@/pages/TeacherDashboard";
import StudentCenter from "@/pages/StudentCenter";
import { createContext, useState } from "react";
import ClassManagement from "@/pages/teacher/ClassManagement";
import StudentManagement from "@/pages/teacher/StudentManagement";
import GradeManagement from "@/pages/teacher/GradeManagement";

export const AuthContext = createContext({
  isAuthenticated: false,
  setIsAuthenticated: (value: boolean) => {},
  logout: () => {},
});

export default function App() {
  const [isAuthenticated, setIsAuthenticated] = useState(false);

  const logout = () => {
    setIsAuthenticated(false);
  };

  return (
    <AuthContext.Provider
      value={{ isAuthenticated, setIsAuthenticated, logout }}
    >
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/teacher-login" element={<TeacherLogin />} />
        <Route path="/student-login" element={<StudentLogin />} />
        <Route path="/teacher/login" element={<TeacherLogin />} />
        <Route path="/student/login" element={<StudentLogin />} />
        <Route path="/student-center" element={<StudentCenter />} />
        <Route path="/teacher-dashboard" element={<TeacherDashboard />}>
          <Route path="class" element={<ClassManagement />} />
          <Route path="students" element={<StudentManagement />} />
          <Route path="grades" element={<GradeManagement />} />
        </Route>
      </Routes>
    </AuthContext.Provider>
  );
}
